package bb.lanxing.calc.processer;

import bb.lanxing.calc.data.DisplayPoint;
import bb.lanxing.calc.data.SourcePoint;

public class SimpleWorkoutProcessor extends BaseWorkoutProcessor {
    @Override
    public void init(int[] dataTypes) {
        initCalc();
        initConfigs();
        initSourceDataPool(dataTypes, null);
    }

    @Override
    public boolean checkPoint(SourcePoint sourcePoint) {
        if (sourcePoint == null) {
            return false;
        }
        if (isTrainingMode()
            ||isIndoorBikeMode()
            ||isCrossTrainerMode()) {
            if (isPaused(sourcePoint)) {
                return false;
            }
            sourcePointPair.update(sourcePoint);
            return true;
        } else if (!isSamePoints(sourcePoint) && checkPointValid(sourcePoint)) {
            sourcePointPair.update(sourcePoint);
            return true;
        } else {
            return false;
        }
    }

    @Override
    public DisplayPoint process(SourcePoint sourcePoint) {
        if (checkPoint(sourcePoint)) {
            calcPoint(sourcePoint);
        }
        updateDisplayPoint(sourcePoint);
        return displayPoint;
    }
}